// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/css/icon.css';
import store from './store'
import {getRequest} from './uitls/api'
import {postRequest} from './uitls/api'
import {deleteRequest} from './uitls/api'
import {putRequest} from './uitls/api'
import {initMenu} from './uitls/utils'
import {isNotNullORBlank} from './uitls/utils'
import './uitls/filter_utils'
import 'font-awesome/css/font-awesome.min.css'
import './components/pages/directives';
import "babel-polyfill";
// 兼容 IE EDGE参数传递
import 'url-search-params-polyfill';
import echarts from 'echarts';
import $ from 'jquery'
// import './node_modules/bootstrap/dist/css/bootstrap.min.css';
// import './node_modules/bootstrap/dist/js/bootstrap.min.js';
Vue.prototype.$echarts = echarts


Vue.config.productionTip = false
Vue.use(ElementUI)

Vue.prototype.getRequest = getRequest;
Vue.prototype.postRequest = postRequest;
Vue.prototype.deleteRequest = deleteRequest;
Vue.prototype.putRequest = putRequest;
Vue.prototype.isNotNullORBlank = isNotNullORBlank;

 router.beforeEach((to, from, next)=>{
  if(to.name == 'Login'){
    next();
    return;
  }
  var name = store.state.user.name;
  if(name == '未登录'){
    if(to.meta. requireAuth || to.name == null){
      next({path:'/',query:{redirect: to.path}})
    }else{
      next();
    }
  }else{
    initMenu(router,store);
    console.log("path.to ---"+to.path)
    if(to.path == '/chat'){
      store.commit("updateMsgList",[]);
    }
    next();
  }
})
 /* eslint-disable no-new */
//  http://zhushou.360.cn/detail/index/soft_id/3919112.html
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})